package com.ruoyi.business.controller;

import com.ruoyi.business.domain.HomeworkStuAnswer;
import com.ruoyi.business.domain.bo.HomeworkStuAnswerBo;
import com.ruoyi.business.service.IHomeworkStuAnswerService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 最爱喝兽奶
 * @create 2022/9/29
 **/
@RestController
@RequestMapping("/business/homeworkStuAnswer")
public class HomeworkStuAnswerController extends BaseController {

    @Autowired
    private IHomeworkStuAnswerService homeworkStuAnswerService;

    @ApiOperation("提交家庭作业")
    @PostMapping("/submit")
    public AjaxResult submitHomework(@RequestBody List<HomeworkStuAnswerBo> list) {
        homeworkStuAnswerService.submitHomework(list);
        return AjaxResult.success();
    }


    @ApiOperation("查询提交的人数")
    @GetMapping("/count/{id}")
    public AjaxResult querySubmitCount(@PathVariable("id") String id) {
        Integer num = homeworkStuAnswerService.querySubmitCount(id);
        return AjaxResult.success(num);
    }

    @ApiOperation("互评")
    @PutMapping
    public AjaxResult submitSubjectiveEvaluation(@RequestBody List<HomeworkStuAnswerBo> bos) {
        homeworkStuAnswerService.submitSubjectiveEvaluation(bos);
        return AjaxResult.success();
    }


}
